import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyString {
    public boolean isNumber(String s) {
        Pattern pattern = Pattern.compile("^\\d+$");
        Matcher matcher = pattern.matcher(s);
        return matcher.matches();
    }

    public boolean isAllUpper(String s) {
        Pattern pattern = Pattern.compile("^[A-Z]+$");
        Matcher matcher = pattern.matcher(s);
        return matcher.matches();
    }

    public boolean isAllLower(String s) {
        Pattern pattern = Pattern.compile("^[a-z]+$");
        Matcher matcher = pattern.matcher(s);
        return matcher.matches();
    }

    public boolean isLetters(String s) {
        Pattern pattern = Pattern.compile("^[a-zA-Z]+$");
        Matcher matcher = pattern.matcher(s);
        return matcher.matches();
    }

    public String toUpper(String s) {
        if (isLetters(s)) {
            s = s.toUpperCase();
            return s;
        }
        return null;
    }

    public int[] sortNumber(String s) {
        if (isNumber(s)) {
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            int[] tmp2 = new int[tmp.length];
            for (int i = 0; i < tmp.length; i++) {
                tmp2[i] = Character.getNumericValue(tmp[i]);
            }
            return tmp2;
        }
        return null;
    }

    public char[] sortLetter(String s) {
        if (isLetters(s)) {
            String s1 = "";
            String[] stringArray = s.split("");
            List<String> stringList = Arrays.asList(stringArray);
            Collections.sort(stringList, String.CASE_INSENSITIVE_ORDER);
            stringArray = stringList.toArray(new String[stringList.size()]);
            for (String t : stringArray) {
                s1 += t;
            }
            return s1.toCharArray();
        }
        return null;
    }
}
